<script lang="ts" setup>
import { defineProps, defineEmits } from "vue"
import CopTodoItem from "../cop-todo-item/index.vue"

import type { TodoItem } from "../../index"

defineProps<{
  todoList: Array<TodoItem>
}>()

const Emit = defineEmits<{
  (e: "removeTodoEvent", index: number): void
  (e: "todoCheckStatusChangeEvent"): void
}>()

const removeTodoEvent = (index: number) => {
  Emit("removeTodoEvent", index)
}
const todoCheckStatusChange = () => {
  Emit("todoCheckStatusChangeEvent")
}
</script>

<template>
  <div class="list">
    <CopTodoItem
      v-for="(todo, i) in todoList"
      :key="i"
      @removeTodoEvent="removeTodoEvent"
      @todoCheckStatusChangeEvent="todoCheckStatusChange"
      :item="todo"
      :index="i"
    />
  </div>
</template>

<style scoped></style>
